package com.example.springmvceasybuy.mapper;


import com.example.springmvceasybuy.entity.News;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface NewsMapper {
    @Insert("INSERT INTO `easybuy_news`(`title`,`content`,`createTime`)\n" +
            "        VALUES(#{title},#{content},#{createTime})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    int insert(News news);
    @Delete("delete from easybuy_news where id=#{id}")
    int delete(@Param("id") Integer id);
    @Update("UPDATE easybuy_news set title=#{title},content=#{content},createTime=#{createTime} where id=#{id}")
    int update(News news);
    @Select("select * from easybuy_news where id=#{id}")
    News selectById(@Param("id") Integer id);
    @Select("select * from easybuy_news where title like concat('%',#{title},'%') order by createTime desc")
    List<News> selectAll(String title);
}
